﻿using System;
using System.Collections.Generic;
using System.Collections;
using System.Text;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using System.Reflection;

namespace MultiConvert
{
    public enum WDSaveFormat : int
    {
        wdFormatDocument = 0,
        wdFormatDOSText = 4,
        wdFormatDOSTextLineBreaks = 5,
        wdFormatEncodedText = 7,
        wdFormatFilteredHTML = 10,
        wdFormatHTML = 8,
        wdFormatRTF = 6,
        wdFormatTemplate = 1,
        wdFormatText = 2,
        wdFormatTextLineBreaks = 3,
        wdFormatUnicodeText = 7,
        wdFormatWebArchive = 9,
        wdFormatXML = 11,
        wdFormatDocument97 = 0,
        wdFormatDocumentDefault = 16,
        wdFormatPDF = 17,
        wdFormatTemplate97 = 1,
        wdFormatXMLDocument = 12,
        wdFormatXMLDocumentMacroEnabled = 13,
        wdFormatXMLTemplate = 14,
        wdFormatXMLTemplateMacroEnabled = 15,
        wdFormatXPS = 18,
    }
        
    [ComImport]
    [Guid("000209FF-0000-0000-C000-000000000046")]
    class MswApplicationClass
    {

    }

    [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
    [Guid("00020970-0000-0000-C000-000000000046")]
    public interface IMswApplication
    {

        [DispId(0x03)]
        IMswDocument ActiveDocument
        {
            [return: MarshalAs(UnmanagedType.Interface)]
            get;
        }


        [DispId(0x06)]        
        IMswDocuments Documents
        {
            [return: MarshalAs(UnmanagedType.Interface)]
            get;
        }
        
        [DispId(8)]
        IMswTemplate NormalTemplate
        {
        	[DispId(8)]
        	[MethodImpl(MethodImplOptions.InternalCall)]
        	[return: MarshalAs(UnmanagedType.Interface)]
        	get;
        }
    }

    [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
    [Guid("0002096B-0000-0000-C000-000000000046")]
    public interface IMswDocument
    {
        [DispId(0x00)]
        String Name
        {
            [return: MarshalAs(UnmanagedType.BStr)]
            get;
        }
    	
    	[DispId(0x03)]
        String Path
        {
            [return: MarshalAs(UnmanagedType.BStr)]
            get;
        }

        [DispId(0x0f)]
        IMswSections Sections
        {
            [return: MarshalAs(UnmanagedType.AsAny)]
            get;
        }

        [DispId(0x0178)]
        void SaveAs([In, Optional, MarshalAs(UnmanagedType.AsAny)] object fileName,
            [In, Optional, MarshalAs(UnmanagedType.AsAny)] object fileFormat,
            [In, Optional, MarshalAs(UnmanagedType.AsAny)] object lockComments,
            [In, Optional, MarshalAs(UnmanagedType.AsAny)] object password,
            [In, Optional, MarshalAs(UnmanagedType.AsAny)] object addtoRecentFiles,
            [In, Optional, MarshalAs(UnmanagedType.AsAny)] object writePassword,
            [In, Optional, MarshalAs(UnmanagedType.AsAny)] object readOnlyRecommended,
            [In, Optional, MarshalAs(UnmanagedType.AsAny)] object embedTrueTypeFonts,
            [In, Optional, MarshalAs(UnmanagedType.AsAny)] object saveFormsData,
            [In, Optional, MarshalAs(UnmanagedType.AsAny)] object saveAsAoceLetter,
            [In, Optional, MarshalAs(UnmanagedType.AsAny)] object encoding,
            [In, Optional, MarshalAs(UnmanagedType.AsAny)] object insertLineBreaks,
            [In, Optional, MarshalAs(UnmanagedType.AsAny)] object allowSubstitutions,
            [In, Optional, MarshalAs(UnmanagedType.AsAny)] object lineEnding,
            [In, Optional, MarshalAs(UnmanagedType.AsAny)] object addBiDiMarks);
        
        [DispId(67)]
        object AttachedTemplate
        {
        	[DispId(67), TypeLibFunc(1024)]        	
        	[return: MarshalAs(UnmanagedType.Struct)]
        	get;
        	
        	[DispId(67), TypeLibFunc(1024)]        	
        	[param: MarshalAs(UnmanagedType.Struct)]
        	set;
        }
        
        
    }


    [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
    [Guid("0002096C-0000-0000-C000-000000000046"), TypeLibType((short) 0x10c0)]
    public interface IMswDocuments
    {
        [DispId(0x02)]
        int Count { [return:MarshalAs(UnmanagedType.I4)] get; }

        [DispId(0x0451)]
        void Close([In, Optional, MarshalAs(UnmanagedType.AsAny)] object saveChanges,
           [In, Optional, MarshalAs(UnmanagedType.AsAny)] object originalFormat,
           [In, Optional, MarshalAs(UnmanagedType.AsAny)] object routeDocument);
       
        
        [DispId(0x13)]
        [return: MarshalAs(UnmanagedType.Interface)]       
        IMswDocument Open([In, MarshalAs(UnmanagedType.AsAny)] object fileName,
             [In, Optional, MarshalAs(UnmanagedType.AsAny)] object confirmConversions,
             [In, Optional, MarshalAs(UnmanagedType.AsAny)] object readOnly,
             [In, Optional, MarshalAs(UnmanagedType.AsAny)] object addToRecentFiles,
             [In, Optional, MarshalAs(UnmanagedType.AsAny)] object passwordDocument,
             [In, Optional, MarshalAs(UnmanagedType.AsAny)] object rasswordTemplate,
             [In, Optional, MarshalAs(UnmanagedType.AsAny)] object revert,
             [In, Optional, MarshalAs(UnmanagedType.AsAny)] object writePasswordDocument,
             [In, Optional, MarshalAs(UnmanagedType.AsAny)] object writePasswordTemplate,
             [In, Optional, MarshalAs(UnmanagedType.AsAny)] object format,
             [In, Optional, MarshalAs(UnmanagedType.AsAny)] object encoding,
             [In, Optional, MarshalAs(UnmanagedType.AsAny)] object visible,
             [In, Optional, MarshalAs(UnmanagedType.AsAny)] object openAndRepair,
             [In, Optional, MarshalAs(UnmanagedType.AsAny)] object documentDirection,
             [In, Optional, MarshalAs(UnmanagedType.AsAny)] object noEncodingDialog,
             [In, Optional, MarshalAs(UnmanagedType.AsAny)] object xmlTransform );

    }

    
    [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
    [Guid("0002095A-0000-0000-C000-000000000046")]
    public interface IMswSections
    {
        [DispId(0x02)]
        int Count
        {
            [return: MarshalAs(UnmanagedType.I4)]
            get;
        }

        [DispId(0x00)]
        [return: MarshalAs(UnmanagedType.AsAny)]
        IMswSection Item([MarshalAs(UnmanagedType.I4)] int index);

    }

    [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
    [Guid("00020959-0000-0000-C000-000000000046")]
    public interface IMswSection
    {
        [DispId(0x0079)]
        IMswHeadersFooters Headers
        {
            [return: MarshalAs(UnmanagedType.AsAny)]
            get;
        }

    }

    [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
    [Guid("00020984-0000-0000-C000-000000000046")]
    public interface IMswHeadersFooters
    {
        [DispId(0x01)]
        int Count
        {
            [return: MarshalAs(UnmanagedType.I4)]
            get;
        }

        [DispId(0x00)]
        [return: MarshalAs(UnmanagedType.AsAny)]
        IMswHeaderFooter Item([MarshalAs(UnmanagedType.I4)] int index);
    }


    [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
    [Guid("00020985-0000-0000-C000-000000000046")]
    public interface IMswHeaderFooter
    {
        [DispId(0x01)]
        int Count
        {
            [return: MarshalAs(UnmanagedType.I4)]
            get;
        }

        [DispId(0x00)]
        IMswRange Range
        {
            [return: MarshalAs(UnmanagedType.AsAny)]
            get;
        }


    }

    [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
    [Guid("0002095E-0000-0000-C000-000000000046")]
    public interface IMswRange
    {
        [DispId(0x0040)]
        IMswFields Fields
        {
            [return: MarshalAs(UnmanagedType.AsAny)]
            get;
        }
    }

    [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
    [Guid("00020930-0000-0000-C000-000000000046")]
    public interface IMswFields
    {
        [DispId(0x01)]
        int Count
        {
            [return: MarshalAs(UnmanagedType.I4)]
            get;
        }

        [DispId(0x0065)]
        [return: MarshalAs(UnmanagedType.I4)]
        int Update();
    }
    
    [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
    [TypeLibType(4288), DefaultMember("Name"), Guid("0002096A-0000-0000-C000-000000000046")]
	public interface IMswTemplate
	{
		[DispId(0)]
		string Name
		{
			[DispId(0)]
			[MethodImpl(MethodImplOptions.InternalCall)]
			[return: MarshalAs(UnmanagedType.BStr)]
			get;
		}
	}
	
	[ComImport, InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
	[Guid("000209A2-0000-0000-C000-000000000046"), TypeLibType(4288)]
	public interface IMswTemplates : IEnumerable
	{
		[DispId(1001)]
		int Creator
		{
			[DispId(1001)]
			[MethodImpl(MethodImplOptions.InternalCall)]
			get;
		}
		[DispId(1002)]
		object Parent
		{
			[DispId(1002)]
			[MethodImpl(MethodImplOptions.InternalCall)]
			[return: MarshalAs(UnmanagedType.IDispatch)]
			get;
		}
		[DispId(1)]
		int Count
		{
			[DispId(1)]
			[MethodImpl(MethodImplOptions.InternalCall)]
			get;
		}
		[DispId(0)]
		IMswTemplate this[[MarshalAs(UnmanagedType.Struct)] [In] object Index]
		{
			[DispId(0)]
			[MethodImpl(MethodImplOptions.InternalCall)]
			[return: MarshalAs(UnmanagedType.Interface)]
			get;
		}
		[TypeLibFunc(1024), DispId(-4)]
		[MethodImpl(MethodImplOptions.InternalCall)]
		[return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "System.Runtime.InteropServices.CustomMarshalers.EnumeratorToEnumVariantMarshaler")]
		new IEnumerator GetEnumerator();
		[DispId(100)]
		[MethodImpl(MethodImplOptions.InternalCall)]
		void LoadBuildingBlocks();
	}
	
} 